import request from '@/api/request'

export const getWorkorders = (params) => request.get('/workorder/list', { params })
export const getWorkorder = (id) => request.get(`/workorder/${id}`)
export const addWorkorder = (data) => request.post('/workorder', data)
export const updateWorkorder = (data) => request.put('/workorder', data)
export const deleteWorkorder = (id) => request.delete(`/workorder/${id}`)
export const completeWorkorder = (id) => request.put(`/workorder/${id}/complete`)
export const returnWorkorder = (id, reason) => request.put(`/workorder/${id}/return`, null, { params: { reason } })
export const importWorkorders = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/workorder/import', formData, { headers: { 'Content-Type': 'multipart/form-data' } })
}
export const exportWorkorders = () => request.get('/workorder/export', { responseType: 'blob' })

export default {
  // 获取客户列表
  getCustomers(params) {
    return request({
      url: '/customer/list',
      method: 'get',
      params
    })
  }
} 